package com.hmall.common.basecontext;

/**
 * 基于ThreadLocal封装工具类，用户保存和获取当前登录用户id
 */
public class BaseContext {
    // ctrl+shift+u 小写变大写
	private static final ThreadLocal<Long> 
        THREAD_LOCAL_USER_ID = new ThreadLocal<>();
	/**
	 * 设置值
	 * @param id
	 */
	public static void setCurrentId(Long id){
		THREAD_LOCAL_USER_ID.set(id);
	}
	/**
	 * 获取值
	 * @return
	 */
	public static Long getCurrentId(){
		return THREAD_LOCAL_USER_ID.get();
	}
}